package FIT::eg::Fixture::Examples;

use FIT::Class;
use FIT::TypeAdapter; # for InputFile and TestResult types
use FIT::Runner::Tally::Types;
use aliased 'FIT::Runner';

extends 'FIT::Fixture::Column';

has location => (is => 'rw', isa => 'InputFile');

# an output field for each possible test result
has [ lc_tally_types ] => (is => 'rw', isa => 'Int');

sub execute {
    my $row     = shift;
    my $context = $self->context;
    my $runner  = Runner->new(
        # run with no parent so we don't get the tally of the child test added
        options => {
            in  => $context->make_in_file(  $self->location )->name,
            out => $context->make_out_file( $self->location )->name,
        },
    );
    $runner->run($self);

    # set results on output columns
    $self->$_( $runner->context->$_ ) for lc_tally_types;
}
